// ssh.js连接远端服务器
const { NodeSSH } = require("node-ssh");
const ssh = new NodeSSH();
const chalk = require("chalk");
const log = console.log;
function connectServe (sshInfo) {
  return new Promise((resolve, reject) => {
    ssh.connect({ ...sshInfo }).then(() => {
     log(chalk.green('' + sshInfo.host + ' 连接成功'))
      resolve(ssh)
    }).catch((err) => {
      reject(log(chalk.red('' + sshInfo.host + ' 连接失败', err)))
    })
  })
}

module.exports = connectServe